const url = './server'

const xhr = new XMLHttpRequest()

xhr.open('GET', url, true)

xhr.onreadystatechange = function() {
    if(this.readyState !== 4) return

    if(this.status === 200) {
        console.log('success')
    } else {
        console.log('error')
    }
}

xhr.onerror = function() {
    console.log('error')
}

xhr.responseType = 'json'
xhr.setRequestHeader('Accept', 'application/json')

xhr.send()